package com.type.web;

import java.util.ArrayList;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.type.service.TypeThree2Service;
import com.type.vo.DeptVO;
import com.type.vo.EmpVO;

@Controller
public class TypeThree2Controller {


	@Resource(name="typeThree2Service")
	private TypeThree2Service typeThree2Service;
	
	@RequestMapping("/typeThree2Result.do")
	public String selectEmpList(Model model){
		ArrayList<EmpVO> list = new ArrayList<EmpVO>();
		try{
			list = typeThree2Service.selectEmpList();
			if(!list.isEmpty()){
			}else{
				model.addAttribute("message","조회할 직원이 없습니다.");
				return "forward:/error.do";
			}
			
		}catch(Exception e){
			model.addAttribute("message","조회할 직원이 없습니다.");
			System.out.println(e.getMessage());
			e.printStackTrace();
			return "forward:/error.do";
		}
		model.addAttribute("selectEmpList",list);
		return "/type/typethree2/typeThree2Result";
	}
	
	@RequestMapping("/typeThree2Tree.do")
	public String selectDeptList(Model model){
		ArrayList<DeptVO> list =new ArrayList<DeptVO>();
		list = typeThree2Service.selectDeptList();
		model.addAttribute("selectDeptList",list);
		return "type/typethree2/typeThree2Tree";
	}

}
